package com.yisu.auction.manager.website.controller.memberInfo;

import com.yisu.auction.ewf.common.web.EasyUIGrid;
import com.yisu.auction.ewf.entity.Recharge;
import com.yisu.auction.manager.core.service.IRechargeService;
import com.yisu.auction.manager.domain.request.memberPackage.RechargeRequest;
import com.yisu.auction.manager.website.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * author: 赵杰
 * Business Description：
 * createTime：2017/9/27
 */
@RequestMapping(value = "/recharge")
@Controller
public class RechargeController extends BaseController {
@Resource
private IRechargeService iRechargeService;


    /**
     * author: 赵杰
     * Business Description：获取会员基本信息
     *
     * @param model
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/index.htm")
    public String index(Model model, HttpServletRequest request, RechargeRequest rechargeRequest) throws Exception {
        try {
            EasyUIGrid<Recharge> memberEasyUIGrid = iRechargeService.getRechargeListByPage(rechargeRequest);
            model.addAttribute("RechargeVos", memberEasyUIGrid.getRows());
            model.addAttribute("currentPage", rechargeRequest.getPage());
            model.addAttribute("totalPages", (rechargeRequest.getTotalRecords() / rechargeRequest.getRows()) + 1);
        } catch (Exception e) {
            logger.error("获取会员基本信息异常：" + e.getMessage());
        }
        return "/memberInfo/rechargeInfo/index";
    }

}
